package net.googlecode.morenko.task5.calculators;

import net.googlecode.morenko.task5.workers.Manager;
import net.googlecode.morenko.task5.workers.Worker;

/**
 * Calculates salary for managers.
 */
public class ManagerCalculator implements Calculator {
    private final int TAX = 250;
    private final int HOURS_PER_MONTH = 170;

    /**
     * @see Calculator
     * @param person
     * @return calculated salary.
     */
    public int calculateSalary(Worker person) {
        Manager manager = (Manager)person;
        int salary = 0;
        if (manager.isPerHour()) {
            salary = HOURS_PER_MONTH * manager.getRate() - TAX;
        }
        else {
            salary = manager.getRate() - TAX;
        }
        if (manager.isHaveBonus()) {
            salary += manager.getBonusAmount();
        }
        return salary;
    }
}
